<template>
	<view class="page">
		<!-- 搜索框 -->
		<view class="article-search">
			<view class="search">
				<view class="location" @click="getLocation">
					<view class="iconfont icon-dingwei"></view> <!-- 这里可以换成定位图标 -->
				</view>
				<input type="text" placeholder="输入搜索内容" v-model="queryList.name" />
				<view class="search-button" @click="btnfn">搜索</view>
			</view>
			<view class="shop" @click="Settled">
				我要入驻
			</view>
			
			
		</view>
		<view class="markList">
			<view class="markItem" v-for="item in markList" @click="markAdress">
				<image class="roundedImage" :src="item.logo_img"></image <view class="title1">

				<view class="title1">
					{{item.store_name}}
				</view>
				<view class="title2">
					{{item.introduce}}
				</view>
			</view>

		</view>
	</view>
	</view>
</template>

<script>
	import {
		getStoreListById
	} from '@/config/api.js';
	export default {
		data() {
			return {
				queryList: {
					navId: null,
					markId: null,
					page: 1,
					name: '',
					limit: 20
				},
				markList: [],
				searchQuery: '', // 存储搜索内容
				location: '', // 存储位置信息
			};
		},
		onLoad(options) {
			// 获取传递的标题
			if (options.title) {
				this.title = decodeURIComponent(options.title); // 解码并设置标题
				uni.setNavigationBarTitle({
					title: this.title // 设置导航栏标题
				});
				this.queryList.navId = options.navId;
				this.queryList.markId = options.markId;
				this.markListById();
			}
		},
		methods: {
			btnfn() {
				console.log(12312312)
			},
			markListById() {
				getStoreListById(this.queryList).then(res => {
					this.markList = res.data;
				})
			},
			//每个商户详情
			markAdress() {
				uni.navigateTo({
					url: '/moduleA/markAddress/markAddress', // 跳转到入驻页面
				});
			},
			// 获取用户定位
			getLocation() {
				uni.getLocation({
					type: 'wgs84',
					success: (res) => {
						this.location = `${res.latitude}, ${res.longitude}`; // 存储经纬度
						uni.showToast({
							title: '定位成功',
							icon: 'success',
						});
						console.log('用户定位:', this.location);
					},
					fail: (err) => {
						uni.showToast({
							title: '获取定位失败',
							icon: 'none',
						});
						console.error(err);
					},
				});
			},
			// 执行搜索
			onSearch() {
				console.log(21312312)
				if (this.queryList.name) {
					this.markListById();
				} else {
					uni.showToast({
						title: '请输入搜索内容',
						icon: 'none',
					});
				}
			},
			// 我要入驻的点击事件
			Settled() {
				uni.navigateTo({
					url: '/moduleA/markList/Settled/Settled', // 跳转到入驻页面
				});
			},
		},
	};
</script>



<style scoped lang="scss">
	@import 'markList.scss';
</style>